package com.liyao.storehouse.service.impl;

import com.liyao.storehouse.dao.jumpDao;
import com.liyao.storehouse.pojo.menu.MenuTwoList;
import com.liyao.storehouse.pojo.menu.MenuType;
import com.liyao.storehouse.service.jumpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @program: storehouse
 * @description:
 * @author: liu yan
 * @create: 2024-11-14 16:55
 */
@Service
public class jumpServerImpl implements jumpService {

    @Resource
    jumpDao dao;
    @Override
    public List<MenuType> getMenuList(Integer user_id, HttpSession session) {
        //获取roleCont
        String roles=dao.getRoles(user_id);
        session.setAttribute("roles",roles);
        String roleb="";
        if(null!=roles && roles.length()>0){
            String [] rolea=roles.split(",");
            for (int i = 0; i < rolea.length; i++) {
                if(!rolea[i].contains("_edit") && !rolea[i].contains("_add") && !rolea[i].contains("_delete")  && !rolea[i].contains("_small")){
                    roleb+=","+rolea[i];
                }
            }
        }else{
            roleb=",0";
        }

        //return dao.getMenuList(user_id,roles);
        return dao.getMenuList2(user_id,roleb.substring(1).split(","));
    }
}
